/*
 * Amiga MUD
 *
 * Copyright (c) 1995 by Chris Gray
 */

/*
 * icons.m - code for dealing with icons.
 *
 *	Note: the makeXXXIcon routines were generated by the icons.d Draco
 *		program.
 */

/*
 * ShowIcon - show this machine's icon to anyone here.
 */

define t_icons proc utility public ShowIconOnce(thing th)void:
    thing me;

    me := Me();
    GShowIcon(th, me, not me@p_pStandard, Parent(me) ~= nil);
corp;

define t_icons proc utility public ShowIcon()void:

    ForEachAgent(Here(), ShowIconOnce);
corp;

/*
 * DoShowIcon - handy for ForceAction on an arriving entity.
 */

define t_icons proc utility public DoShowIcon()status:

    ShowIcon();
    continue
corp;

/*
 * UnShowIcon - remove my icon from anyone else here.
 */

define t_icons proc utility UnShowIconOnce(thing th)void:
    thing me;

    me := Me();
    if (me@p_pIcon ~= nil or me@p_pStandard) and Parent(me) = nil then
	/* If the player or machine has a specific icon, or this is a
	   player or a "standard" machine (Packrat, etc.), and this is
	   not a cloned entity, then we just tell the client to undisplay
	   the icon, but to remember it for later use. */
	GRemoveIcon(th, me);
    else
	/* Otherwise, we tell the client to undisplay the icon, but also to
	   forget it, since the thing associated with it may be reused later
	   for something with a different icon. */
	GDeleteIcon(th, me);
    fi;
corp;

define t_icons proc utility public UnShowIcon()void:

    ForEachAgent(Here(), UnShowIconOnce);
corp;

/*
 * DoUnShowIcon - handy for ForceAction on a leaving entity.
 */

define t_icons proc utility public DoUnShowIcon()status:

    UnShowIcon();
    continue
corp;

/*
 * PrintIcon - print an icon in binary form.
 */

define t_icons proc PrintIcon(list int icon)void:
    int i, bits, j;

    for i from 0 upto 7 do
	Print("icon[" + IntToString(i) + "] := 0b");
	bits := icon[i];
	for j from 0 upto 31 do
	    if bits < 0 then
		Print("1");
	    else
		Print("0");
	    fi;
	    bits := bits << 1;
	od;
	Print(";\n");
    od;
corp;

/*
 * some specific icons
 */

define t_icons proc makeCaretakerIcon()list int:
    list int icon;

    icon := CreateIntArray(8);
    icon[0] := 0b00000000000000000001100000000000;
    icon[1] := 0b00011000000000000000110000000000;
    icon[2] := 0b00001100000000000000011000000000;
    icon[3] := 0b00000110000000000000001100000000;
    icon[4] := 0b00000011000000000000000110000000;
    icon[5] := 0b00000001111000000000001111100000;
    icon[6] := 0b00000011111100000000000111110000;
    icon[7] := 0b00000001100000000000000000000000;
    icon
corp;

define t_icons proc makePackratIcon()list int:
    list int icon;

    icon := CreateIntArray(8);
    icon[0] := 0b00000000000000000000000000000000;
    icon[1] := 0b00000000000000000000000100000000;
    icon[2] := 0b00000010100000000001101011100000;
    icon[3] := 0b00100111100100000001111111100000;
    icon[4] := 0b00000111010000000000110110100000;
    icon[5] := 0b00010101011000000010001000000000;
    icon[6] := 0b00100000000000000100000000000000;
    icon[7] := 0b01000000000000000000000000000000;
    icon
corp;

define t_icons proc makePostmanIcon()list int:
    list int icon;

    icon := CreateIntArray(8);
    icon[0] := 0b00000000000000000000000000000000;
    icon[1] := 0b00000000000000000000000000000000;
    icon[2] := 0b01111111111111100111000000001110;
    icon[3] := 0b01001100001100100100001111000010;
    icon[4] := 0b01000000000000100111111111111110;
    icon[5] := 0b00000000000000000000000000000000;
    icon[6] := 0b00000000000000000000000000000000;
    icon[7] := 0b00000000000000000000000000000000;
    icon
corp;

define t_icons proc makeQuestorIcon()list int:
    list int icon;

    icon := CreateIntArray(8);
    icon[0] := 0b00000000000000000000000000000000;
    icon[1] := 0b00000111111000000001100000011000;
    icon[2] := 0b00100000000001000100000000000010;
    icon[3] := 0b01000000000000100100000000000010;
    icon[4] := 0b01000000000000100100100000000010;
    icon[5] := 0b01000110000000100010000110000100;
    icon[6] := 0b00011000010110000000011111100000;
    icon[7] := 0b00000000000111000000000000000011;
    icon
corp;

define t_icons proc makeMerlinIcon()list int:
    list int icon;

    icon := CreateIntArray(8);
    icon[0] := 0b00000000000000000000000000000000;
    icon[1] := 0b00000001111110000000001000000100;
    icon[2] := 0b00000100001110100000010000100110;
    icon[3] := 0b00001000000100000000100000010000;
    icon[4] := 0b00010010010010000001000110001000;
    icon[5] := 0b00100111111001000010000110000100;
    icon[6] := 0b01000010010000100100000000000010;
    icon[7] := 0b00111111111111000000000000000000;
    icon
corp;

define t_icons proc makeWandererIcon()list int:
    list int icon;

    icon := CreateIntArray(8);
    icon[0] := 0b00000000000000000000011111100000;
    icon[1] := 0b00001000000100000001000000001000;
    icon[2] := 0b00100011110001000100010000100010;
    icon[3] := 0b01001000000100100100100110010010;
    icon[4] := 0b01001001100100100100100000010010;
    icon[5] := 0b01000100001000100010001111000100;
    icon[6] := 0b00010000000010000000100000010000;
    icon[7] := 0b00000111111000000000000000000000;
    icon
corp;

define t_icons proc makeBirdIcon()list int:
    list int icon;

    icon := CreateIntArray(8);
    icon[0] := 0b00000000000000000000011110000000;
    icon[1] := 0b00011111110000000011111111100000;
    icon[2] := 0b00111111111000000111111011111000;
    icon[3] := 0b01111110011111100111111111110000;
    icon[4] := 0b01111111111111100111111111110000;
    icon[5] := 0b00111111111000000011111111000000;
    icon[6] := 0b00011111110000000000011110000000;
    icon[7] := 0b00000000000000000000000000000000;
    icon
corp;

define t_icons proc makeRockPileIcon()list int:
    list int li;

    li := CreateIntArray(8);
    li[0] := 0b00000000000000000000000000000000;
    li[1] := 0b00000000000000000000000000000000;
    li[2] := 0b00000000000000000000000000000000;
    li[3] := 0b00000000000000000000110001110000;
    li[4] := 0b00010010100010000001101110000100;
    li[5] := 0b00110100101101000010100001001100;
    li[6] := 0b01001011010100100100110010001010;
    li[7] := 0b00110011011101000000000000000000;
    li
corp;
